1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.BitsetIter;
26 
27 private import glib.MemorySlice;
28 private import gobject.ObjectG;
29 private import gtk.Bitset;
30 private import gtk.c.functions;
31 public  import gtk.c.types;
32 
33 
34 /**
35  * An opaque, stack-allocated struct for iterating
36  * over the elements of a `GtkBitset`.
37  * 
38  * Before a `GtkBitsetIter` can be used, it needs to be initialized with
39  * [func@Gtk.BitsetIter.init_first], [func@Gtk.BitsetIter.init_last]
40  * or [func@Gtk.BitsetIter.init_at].
41  */
42 public class BitsetIter
43 {
44 	/** the main Gtk struct */
45 	protected GtkBitsetIter* gtkBitsetIter;
46 	protected bool ownedRef;
47 
48 	/** Get the main Gtk struct */
49 	public GtkBitsetIter* getBitsetIterStruct(bool transferOwnership = false)
50 	{
51 		if (transferOwnership)
52 			ownedRef = false;
53 		return gtkBitsetIter;
54 	}
55 
56 	/** the main Gtk struct as a void* */
57 	protected void* getStruct()
58 	{
59 		return cast(void*)gtkBitsetIter;
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (GtkBitsetIter* gtkBitsetIter, bool ownedRef = false)
66 	{
67 		this.gtkBitsetIter = gtkBitsetIter;
68 		this.ownedRef = ownedRef;
69 	}
70 
71 
72 	/** */
73 	public static GType getType()
74 	{
75 		return gtk_bitset_iter_get_type();
76 	}
77 
78 	/**
79 	 * Gets the current value that @iter points to.
80 	 *
81 	 * If @iter is not valid and [method@Gtk.BitsetIter.is_valid]
82 	 * returns %FALSE, this function returns 0.
83 	 *
84 	 * Returns: The current value pointer to by @iter
85 	 */
86 	public uint getValue()
87 	{
88 		return gtk_bitset_iter_get_value(gtkBitsetIter);
89 	}
90 
91 	/**
92 	 * Checks if @iter points to a valid value.
93 	 *
94 	 * Returns: %TRUE if @iter points to a valid value
95 	 */
96 	public bool isValid()
97 	{
98 		return gtk_bitset_iter_is_valid(gtkBitsetIter) != 0;
99 	}
100 
101 	/**
102 	 * Moves @iter to the next value in the set.
103 	 *
104 	 * If it was already pointing to the last value in the set,
105 	 * %FALSE is returned and @iter is invalidated.
106 	 *
107 	 * Params:
108 	 *     value = Set to the next value
109 	 *
110 	 * Returns: %TRUE if a next value existed
111 	 */
112 	public bool next(out uint value)
113 	{
114 		return gtk_bitset_iter_next(gtkBitsetIter, &value) != 0;
115 	}
116 
117 	/**
118 	 * Moves @iter to the previous value in the set.
119 	 *
120 	 * If it was already pointing to the first value in the set,
121 	 * %FALSE is returned and @iter is invalidated.
122 	 *
123 	 * Params:
124 	 *     value = Set to the previous value
125 	 *
126 	 * Returns: %TRUE if a previous value existed
127 	 */
128 	public bool previous(out uint value)
129 	{
130 		return gtk_bitset_iter_previous(gtkBitsetIter, &value) != 0;
131 	}
132 
133 	/**
134 	 * Initializes @iter to point to @target.
135 	 *
136 	 * If @target is not found, finds the next value after it.
137 	 * If no value >= @target exists in @set, this function returns %FALSE.
138 	 *
139 	 * Params:
140 	 *     iter = a pointer to an uninitialized `GtkBitsetIter`
141 	 *     set = a `GtkBitset`
142 	 *     target = target value to start iterating at
143 	 *     value = Set to the found value in @set
144 	 *
145 	 * Returns: %TRUE if a value was found.
146 	 */
147 	public static bool initAt(out BitsetIter iter, Bitset set, uint target, out uint value)
148 	{
149 		GtkBitsetIter* outiter = sliceNew!GtkBitsetIter();
150 
151 		auto __p = gtk_bitset_iter_init_at(outiter, (set is null) ? null : set.getBitsetStruct(), target, &value) != 0;
152 
153 		iter = ObjectG.getDObject!(BitsetIter)(outiter, true);
154 
155 		return __p;
156 	}
157 
158 	/**
159 	 * Initializes an iterator for @set and points it to the first
160 	 * value in @set.
161 	 *
162 	 * If @set is empty, %FALSE is returned and @value is set to %G_MAXUINT.
163 	 *
164 	 * Params:
165 	 *     iter = a pointer to an uninitialized `GtkBitsetIter`
166 	 *     set = a `GtkBitset`
167 	 *     value = Set to the first value in @set
168 	 *
169 	 * Returns: %TRUE if @set isn't empty.
170 	 */
171 	public static bool initFirst(out BitsetIter iter, Bitset set, out uint value)
172 	{
173 		GtkBitsetIter* outiter = sliceNew!GtkBitsetIter();
174 
175 		auto __p = gtk_bitset_iter_init_first(outiter, (set is null) ? null : set.getBitsetStruct(), &value) != 0;
176 
177 		iter = ObjectG.getDObject!(BitsetIter)(outiter, true);
178 
179 		return __p;
180 	}
181 
182 	/**
183 	 * Initializes an iterator for @set and points it to the last
184 	 * value in @set.
185 	 *
186 	 * If @set is empty, %FALSE is returned.
187 	 *
188 	 * Params:
189 	 *     iter = a pointer to an uninitialized `GtkBitsetIter`
190 	 *     set = a `GtkBitset`
191 	 *     value = Set to the last value in @set
192 	 *
193 	 * Returns: %TRUE if @set isn't empty.
194 	 */
195 	public static bool initLast(out BitsetIter iter, Bitset set, out uint value)
196 	{
197 		GtkBitsetIter* outiter = sliceNew!GtkBitsetIter();
198 
199 		auto __p = gtk_bitset_iter_init_last(outiter, (set is null) ? null : set.getBitsetStruct(), &value) != 0;
200 
201 		iter = ObjectG.getDObject!(BitsetIter)(outiter, true);
202 
203 		return __p;
204 	}
205 }